﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;

namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class PhieuKHDatHangBlo
    {
        #region "Khai báo các biến"
        private PhieuKHDatHangDAO da;
        private PhieuKHDatHangDTO _KHDH;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public PhieuKHDatHangDTO KHDH
        {
            get { return _KHDH; }
            set { _KHDH = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public PhieuKHDatHangBlo()
        {            
            da = new PhieuKHDatHangDAO();
        }
        public bool InsertPhieuKHDatHang(string makhdh, string makho, string makh, string manv, string sochungtu, DateTime ngaythangdh, string diachi, string ghichudh, double tongtien, double tamung, double conlai, DateTime ngaybangiao)
        {
            _KHDH = new PhieuKHDatHangDTO(makhdh, makho, makh, manv, sochungtu,ngaythangdh,diachi,ghichudh,tongtien,tamung,conlai,ngaybangiao);
            if (!da.InsertPhieuKHDatHang(KHDH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdatePhieuKHDatHang(string makhdh, string makho, string makh, string manv, string sochungtu, DateTime ngaythangdh, string diachi, string ghichudh, double tongtien, double tamung, double conlai, DateTime ngaybangiao)
        {
            _KHDH = new PhieuKHDatHangDTO(makhdh, makho, makh, manv, sochungtu, ngaythangdh, diachi, ghichudh, tongtien, tamung, conlai, ngaybangiao);
            if (!da.UpdatePhieuKHDatHang(KHDH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeletePhieuKHDatHang(string maKHDH)
        {
            if (!da.DeletePhieuKHDatHang(maKHDH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_PhieuKHDatHang()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_PhieuKHDatHang();
            return ds;
        }
        #endregion 
    }
}